package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ResourceDto;
import com.zzyl.service.ResourceService;
import com.zzyl.vo.ResourceVo;
import com.zzyl.vo.TreeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "资源管理")
@RequestMapping("/resource")
public class ResourceController {
 @Autowired
 private ResourceService resourceService;
 @PostMapping("/list")
 @ApiOperation("列表管理")
 public ResponseResult<List<ResourceVo>> resourceList(@RequestBody ResourceDto resourceDto){
  List<ResourceVo> resourceList=resourceService.selectList(resourceDto);
  return ResponseResult.success(resourceList);
 }
 @ApiOperation("查看树形资源")
 @PostMapping("/tree")
 public ResponseResult<TreeVo> resourceTreeVo(@RequestBody ResourceDto resourceDto) {
  TreeVo treeVo = resourceService.resourceTreeVo(resourceDto);

  return ResponseResult.success(treeVo);
 }

 @ApiOperation("资源添加")
 @PutMapping
 public ResponseResult<ResourceVo> createResource(@RequestBody ResourceDto resourceDto) {
  Boolean flag = resourceService.createResource(resourceDto);
  return ResponseResult.success(flag);
 }

}
